﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Phase_lookup_form.aspx.cs" Inherits="m_gestione_Phase_Phase_lookup_list" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Phase</title>
    <link href="/timereport/include/commoncss.aspx" rel="stylesheet" type="text/css" />
</head>
    <script language="JavaScript" src="/timereport/include/menu/menu_array.js" type="text/javascript"></script>
    <script language="JavaScript" src="/timereport/include/menu/mmenu.js" type="text/javascript"></script>
<body>

<table width="760" border="0">
        <tr>
            <td height="30" class="BarraTop" align="right">Utente: <%= Session["UserName"] %>
            </td>
        </tr>
          <tr>
            <td height="30">&nbsp;</td>
           </tr>

    <tr><td>

    <form id="form1" runat="server">

    <asp:FormView ID="SchedaFase" runat="server" DataKeyNames="Phase_id" 
        DataSourceID="DSPhase" EnableModelValidation="True" DefaultMode="Insert"
        align="center" oniteminserted="SchedaFase_ItemInserted" 
        onitemupdated="SchedaFase_ItemUpdated" onmodechanging="SchedaFase_ModeChanging">
        
        <EditItemTemplate>
          <table class="TabellaForm" width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                 <th>PhaseCode:</th>
                 <td><asp:TextBox ID="PhaseCodeTextBox" runat="server" 
                         Text='<%# Bind("PhaseCode") %>' CssClass="FormInputDisabled" 
                         ReadOnly="True"/> 
                 </td>
            </tr>
            <tr>
            <th>Name:</th>
            <td><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="(*)" ControlToValidate="NameTextBox"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
            <th>Projects_id:</th>
            <td><asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="DSProject" 
                    DataTextField="ProjectName" DataValueField="Projects_Id" 
                    SelectedValue='<%# Bind("Projects_Id") %>'></asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="(*)" ControlToValidate="DropDownList1"></asp:RequiredFieldValidator>
                    </td>
                </table>

                    <br />
                <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Aggiorna" CssClass="FormButton" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" 
                    CssClass="FormButton" />

        </EditItemTemplate>
        <InsertItemTemplate>

            <table class="TabellaForm" width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                 <th>PhaseCode:</th>
                 <td><asp:TextBox ID="PhaseCodeTextBox" runat="server" Text='<%# Bind("PhaseCode") %>'/> 
                  <asp:CustomValidator ID="ValidaFase" runat="server" Display="Dynamic" ErrorMessage="Codice fase già esistente" OnServerValidate="ValidaFase_ServerValidate" ControlToValidate="PhaseCodeTextBox"></asp:CustomValidator>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="PhaseCodeTextBox" ErrorMessage="(*)"></asp:RequiredFieldValidator>
                 </td>
            </tr>
            <tr>
            <th>Name:</th>
            <td><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="(*)" ControlToValidate="NameTextBox"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
            <th>Projects_id:</th>
            <td><asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="DSProject" 
                    DataTextField="ProjectName" DataValueField="Projects_Id" 
                    SelectedValue='<%# Bind("Projects_Id") %>' AppendDataBoundItems="True">
                    <asp:ListItem  Value="" Text="-- Selezionare un valore --"/>
                    </asp:DropDownList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="(*)" ControlToValidate="DropDownList1"></asp:RequiredFieldValidator>
                </td>
                </table>
                    <br />
                <asp:Button ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" CssClass="FormButton" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" 
                    CssClass="FormButton" />

        </InsertItemTemplate>
        <ItemTemplate>
            Phase_id:
            <asp:Label ID="Phase_idLabel" runat="server" Text='<%# Eval("Phase_id") %>' />
            <br />
            PhaseCode:
            <asp:Label ID="PhaseCodeLabel" runat="server" Text='<%# Bind("PhaseCode") %>' />
            <br />
            Name:
            <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
            <br />
            Projects_id:
            <asp:Label ID="Projects_idLabel" runat="server" 
                Text='<%# Bind("Projects_id") %>' />
            <br />

        </ItemTemplate>
    </asp:FormView>
     
    </form>

    </td></tr>           

    </table>
    <asp:SqlDataSource ID="DSPhase" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
        SelectCommand="SELECT * FROM [Phase] WHERE ([Phase_id] = @PhaseId)" 
        InsertCommand="INSERT INTO [Phase] ([PhaseCode], [Name], [Projects_id]) VALUES (@PhaseCode, @Name, @Projects_id)" 
        UpdateCommand="UPDATE [Phase] SET [PhaseCode] = @PhaseCode, [Name] = @Name, [Projects_id] = @Projects_id WHERE [Phase_id] = @Phase_id">        

        <SelectParameters>
        <asp:QueryStringParameter Name="PhaseId" QueryStringField="PhaseId" Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="PhaseCode" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Projects_id" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="PhaseCode" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Projects_id" Type="Int32" />
            <asp:Parameter Name="Phase_id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="DSProject" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
        
        SelectCommand="SELECT Projects_Id, ProjectCode + N' ' + Name AS ProjectName FROM Projects WHERE (ClientManager_id = @ClientManager_id) AND (Active = 1) and (ActivityOn = 1)" 
        onselecting="DSProject_Selecting">
        <SelectParameters>
            <asp:Parameter Name="ClientManager_id" />
        </SelectParameters>
    </asp:SqlDataSource>

</body>

</html>
